import { createSSRApp } from 'vue'
import App from '@/App.vue'
import store from '@/store'

// 插件
import plugins from './core/plugins' // plugins
// 权限
import './permission' // permission
// 全局样式
import '@/static/styles/index.scss'

// uv-ui 样式框架扩展
import uvUI from '@climblee/uv-ui'
import uvUICustom from '@/core/uvui/custom'
import uvRequestCustom from '@/core/uvui/request'

// 字典工具
import { useDict, selectDictLabel, selectDictLabels } from '@/core/utils/dict'
// 系统配置
import { getConfigKey } from '@/api/system/config.api'

/**
 * 创建应用
 */
export function createApp() {
  const app = createSSRApp(App)
  app.use(uvUI)
  uvUICustom()
  uvRequestCustom()

  // 全局挂载函数
  app.config.globalProperties.useDict = useDict
  app.config.globalProperties.selectDictLabel = selectDictLabel
  app.config.globalProperties.selectDictLabels = selectDictLabels
  app.config.globalProperties.getConfigKey = getConfigKey

  app.use(store)
  app.use(plugins)
  return {
    app
  }
}
